{include file='common/head'}
<div style="overflow-x: hidden;width: 96%;margin: auto;padding-top: 1rem;">

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>{$info['table_title']|default='数据列表信息'}</legend>
    </fieldset>

    <div class="layui-form">
        <input type="hidden" name="id" value="{$info.id|default=''}" id="id">
        <div class="layui-form-item">
            <label class="layui-form-label">角色名称</label>
            <div class="layui-input-inline">
                <div class="layui-input-inline">
                    <input type="text" value="{$info['name']|default=''}" name="name" lay-verify="required"  class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <input type="text"  value="{$info['desc']|default=''}" name="desc" lay-verify="required" class="layui-input">

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">角色状态</label>
            <div class="layui-input-inline">
                <div class="layui-input-inline">
                    <select name="status" lay-verify="required">
                        <option value="1" {if isset($info)}{if $info.status==1}selected{/if}{/if}>正常</option>
                        <option value="2" {if isset($info)}{if $info.status==2}selected{/if}{/if}>禁用</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary" id="closeIframe">关闭</button>
            </div>
        </div>
    </div>
</div>
{include file='common/footer'}

<!-- 配置文件 -->
<script type="text/javascript" src="/static/admin/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/static/admin/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script>
    var ue = UE.getEditor('container');
</script>

<script>
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(demo1)', function(data){
            var id=$('#id').val();
            data.field['id']=id;
            $.post('{:url("Role/ApiSaveRoleInfo")}',data.field,function (obj) {
                if(obj.code == 200){
                    parent.layer.msg(obj.msg, {icon: 6,time: 1000});
                    //当你在iframe页面关闭自身时
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index,data.field); //再执行关闭
                }
                if(obj.code == 400){
                    parent.layer.msg(obj.msg, {icon: 5,time: 1000});
                }
            },"JSON");
        });
        $('#closeIframe').click(function(){
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
    });
</script>

</body>
</html>